#include <bits/stdc++.h>
#define ll long long
#define debug(...) fprintf(stderr,__VA_ARGS__)
using namespace std;

char ibuf[1<<21],*iptr=ibuf;
inline static int read(){
    int sum=0,ch=*iptr++;
    while(!isdigit(ch)) ch=*iptr++;
    while(isdigit(ch)) sum=sum*10+(ch^48),ch=*iptr++;
    return sum;
}

constexpr int mod=1e9+7,inv2=5e8+4;
int n,fa[200005],e[200005],head[200005];
int ht[200005],son[200005],siz[200005];
int a[200005],b[200005],os[200005];
int pow2(int b,int ret=1){
    for(ll a=2;b;a=a*a%mod,b>>=1)
        if(b&1) ret=ret*a%mod; return ret;
}
signed main(){
    freopen("a.in","r",stdin);
    freopen("a.out","w",stdout);
    fread(ibuf,1,1<<21,stdin),n=read()+1; for(int i=2;i<=n;i++) fa[i]=read()+1;
    for(int i=n,p;i>=1;i--) if(++ht[i]>ht[p=fa[i]]) ht[p]=ht[i],son[p]=i;
    for(int i=1,p=0,u;i<=n;os[son[i]]=os[i]+1,i++) if(!os[i])
        os[i]=p,p+=ht[i],u=fa[i],e[i]=head[u],head[u]=i,siz[u]=max(siz[u],ht[i]);
    for(int i=n;i>=1;a[os[i]]=inv2,i--){
        for(int j=0;j<siz[i];j++) b[j]=1-a[os[i]+j+1];
        for(int j=head[i];j;j=e[j]) for(int k=0,p=os[i]+1,q=os[j];k<ht[j];k++,p++,q++){
            a[p]=(a[p]*(1ll-a[q])+(ll)b[k]*a[q])%mod,b[k]=b[k]*(1ll-a[q])%mod;
        }
    } return printf("%lld\n",(accumulate(a,a+ht[1],0ll)%mod+mod)*pow2(n)%mod),0;
}
